#include "mainwindow.h"
#include "ui_mainwindow.h"


MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    InputStream=new CInput();
     QObject::connect (InputStream,SIGNAL(ProcessMassage(QString)),this,SLOT(DebagAdded(QString)));
     QObject::connect (ui->ASave,SIGNAL(triggered()),this,SLOT(Save()));
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_OpenImage_clicked()
{
    ui->label->setPixmap(InputStream->OpenImage ());
}

void MainWindow::on_Start_clicked()
{
    InputStream->SetMessage (ui->textEdit->toPlainText ());
    InputStream->SetKey (ui->lineEdit->text ());
}

void MainWindow::Save()
{
    InputStream->SaveImage ();
}

void MainWindow::on_SetRandomKey_clicked()
{
    InputStream->SetRandomKey ();
    ui->lineEdit->setText (InputStream->GetKey ());
}

void MainWindow::on_SetRandomMessage_clicked()
{
    InputStream->SetRandomMessage ();
    ui->textEdit->setText (InputStream->GetMessage ());
}

void MainWindow::DebagAdded(QString AddingMessage)
{
    ui->textEdit_2->append(AddingMessage);
}

void MainWindow::on_comboBox_2_currentTextChanged(const QString &arg1)
{
    InputStream->TurnWorkMode ();
}
